﻿using System;
using System.Data;
using System.Drawing;
using System.Windows.Forms;

namespace TaxiDispatchClient
{
    public partial class SmsMessageBox : DevExpress.XtraEditors.XtraForm
    {
        private readonly int _x;//当前窗体X坐标
        private int _y;
        internal enum Direction
        {
            Up, Down
        }

        public string PhoneNumber = string.Empty;
        public string Recedatetime = string.Empty;
        public string Rececontent = string.Empty;
        public DataTable DtTaxiList = new DataTable();

        public SmsMessageBox()
        {
            InitializeComponent();

            _x = Screen.PrimaryScreen.WorkingArea.Width - Width;
            _y = Screen.PrimaryScreen.WorkingArea.Height;
            Location = new Point(this._x, this._y);

        }

        public SmsMessageBox(string phoneNum, string receTime, string content,DataTable  dt)
        {
            InitializeComponent();

            _x = Screen.PrimaryScreen.WorkingArea.Width - Width;
            _y = Screen.PrimaryScreen.WorkingArea.Height;
            Location = new Point(this._x, this._y);

            labelControl_phoneNum.Text = phoneNum;
            PhoneNumber = phoneNum;
            labelControl_receDateTime.Text = receTime;
            Recedatetime = receTime;
            textEdit_receContent.Text = content;
            Rececontent = content;

            DtTaxiList = dt.Copy();
        }

        private void SmsMessageBox_Shown(object sender, EventArgs e)
        {
            while (_y > Screen.PrimaryScreen.WorkingArea.Height - Height)
            {
                _y--;
                Location = new Point(_x, _y);
                System.Threading.Thread.Sleep(0);
            }
        }

        private void SmsMessageBox_FormClosing(object sender, FormClosingEventArgs e)
        {
            while (_y < Screen.PrimaryScreen.WorkingArea.Height)
            {
                _y++;
                Location = new Point(_x, _y);
                System.Threading.Thread.Sleep(0);
            }
        }


        private void pictureEdit2_Click(object sender, EventArgs e)
        {
            Hide();
            SendSms sendSms = new SendSms(this);
            sendSms.Show();
        }

        private void pictureEdit1_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void Form_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                Close();
            }
        }
    }
}